#include<stdio.h>
int main()
{
	int i,j,num,t,a[10];
	int low,high;
	scanf("%d",&num);
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<9;i++){
		for(j=0;j<9-i;j++){
			if(a[j]>a[j+1]){
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;
			}
		}
	}
	for(low=0,high=9;low<high;){
		if(a[low]+a[high]==num){
			printf("%d%d\n",a[low],a[high]);
			low++;
		}
		else if(a[low]+a[high]>num){
			high--;
		}
		else{
			low++;
		}
	}
	return 0;
}
